﻿using System.Collections.Generic;

namespace com.foxmail.wyyuan1991.Assignment.Solver.Dijstra
{
    public class RoutePlanResult : IRoute
    {
        public virtual IList<INode> NodeList { get; set; }
        public virtual IList<IArc> ArcList { get; set; }
        public INode DesNode
        {
            get
            {
                if (this.NodeList != null && this.NodeList.Count > 0)
                {
                    return this.NodeList[this.NodeList.Count-1];
                }
                else
                {
                    return null;
                }
            }
        }
        public INode OrgNode
        {
            get
            {
                if (this.NodeList != null && this.NodeList.Count > 0)
                {
                    return this.NodeList[0];
                }
                else
                {
                    return null;
                }
            }
        }
        public override string ToString()
        {
            if (this.NodeList != null && this.NodeList.Count > 0)
            {
                string s = "";
                s += this.OrgNode.ID;
                for (int i = 1; i < NodeList.Count-1; i++)
                {
                    s += "--"+ArcList[i-1].ID+"-->"+NodeList[i].ID;
                }
                return s;
            }
            else
            {
                return "无有效路径";
            }
        }
    }
}